
// hotel-management-frontend/src/App.js

import React from 'react';
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
import AppLayout from './components/Layout'; // Your common layout component

// Admin components
import RoomManagement from './admin/RoomManagement';
import GuestManagement from './admin/GuestManagement';
import CheckinManagement from './admin/CheckinManagement';
import Statistics from './admin/Statistics';
import Dashboard from './admin/Dashboard';
import BulkImport from './admin/BulkImport';

// Client components
import ClientHistory from './client/History'; // Customer check-in/consumption history
import ClientProfile from './client/Profile'; // Customer personal info query (e.g., by ID)

// Admin Routes Wrapper - Uses AppLayout with isAdmin=true
const AdminRoutes = () => (
    <AppLayout isAdmin={true}>
        <Routes>
            <Route path="dashboard" element={<Dashboard />} />
            <Route path="rooms" element={<RoomManagement />} />
            <Route path="guests" element={<GuestManagement />} />
            <Route path="checkins" element={<CheckinManagement />} />
            <Route path="statistics" element={<Statistics />} />
            <Route path="bulk-import" element={<BulkImport />} />
            {/* Redirect any unhandled /admin/* routes to /admin/dashboard */}
            <Route path="*" element={<Navigate to="dashboard" replace />} />
        </Routes>
    </AppLayout>
);

function App() {
    return (
        <Router>
            <Routes>
                {/* Admin section: All routes starting with /admin */}
                <Route path="/admin/*" element={<AdminRoutes />} />

                {/* Client section: Specific routes for client functionalities */}
                {/* Client Homepage - Can be a welcome page or default to history */}
                <Route path="/" element={<AppLayout isAdmin={false}><ClientHistory /></AppLayout>} />

                {/* Specific Client History page */}
                <Route path="/client/history" element={<AppLayout isAdmin={false}><ClientHistory /></AppLayout>} />

                {/* Specific Client Profile page */}
                <Route path="/client/profile" element={<AppLayout isAdmin={false}><ClientProfile /></AppLayout>} />

                {/* Fallback route: Redirects any unhandled path to the client homepage */}
                <Route path="*" element={<Navigate to="/" replace />} />
            </Routes>
        </Router>
    );
}

export default App;